<?php
//class Admin_model extends Model{
class Admin_model{
	static $dbconfig = array();
	
    public  function __construct($db){	
		self::$dbconfig = $db;
		return Model::connect(self::$dbconfig['host'],self::$dbconfig['username'],self::$dbconfig['password'],self::$dbconfig['dbname'],self::$dbconfig['pconnect'],self::$dbconfig['char_set']);
	}
	
   function selectCode($username){
		$sqlCheckcode = Model::sqlChange('getCheckCode',$username);
		$result = Model::fetchOne($sqlCheckcode);
		if($result) return $result; 
		else return false;
	}
    
    function get_style(){
		$sql_style = Model::sqlChange('getStyle');
        // var_dump($sql_style);
          $result = Model::fetALL($sql_style);
		if($result) return $result;
        else return false;	
    }
    
    function insert_new($news =array()){
		if(is_array($news)){
			$sql_save_news = Model::sqlChange('save_news',array('title'=>$news['title'],'style'=>$news['style'],'current_date'=>$news['current_date'],'endtime'=>$news['endtime'],'publices'=>$news['publices'],'content'=>$news['content'],'admins'=>$news['admins']));
            // var_dump($sql_save_news);
            // exit();
               $counts = Model::exec($sql_save_news);
               return $counts;
        }
    }
    
    function get_style_count(){
		$sql_style_count = Model::sqlChange('sty_counts');
           $counts = Model::fetchOne($sql_style_count);
           if($counts) return $counts;
           else return '';
    }
    
    function update_sty($id,$select_sty){
		  $result_sql = Model::sqlChange('update_sty',array('style_name'=>urldecode($select_sty),'style_id'=>$id));
		  var_dump($result_sql);

	        $couns = Model::exec($result_sql);
	        if($couns) return $couns;
	        else return '';
    }
}
?>
